#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include<assert.h>
typedef struct people
{
    int number;
    struct people* next;
}people;
void SLpush(people* head, int val)
{
    people* nhead = head;
    assert(head);
    people* new = (people*)malloc(sizeof(people));
    new->number = val;
    while (nhead->next->number != head->number)
    {
        nhead = nhead->next;
    }
    new->next = nhead->next;
    nhead->next = new;
}
int is_7(int x)
{
    if (x / 7 != 0 && x % 7 == 0)
        return 1;
    while (x)
    {
        if (x % 10 == 7)
            return 1;
        x /= 10;
    }
    return 0;
}
int main()
{
    people head;
    head.next = &head;
    head.number = 0;
    SLpush(&head, 0);
    SLpush(&head, 0);
    SLpush(&head, 0);
    int n = 0;
    scanf("%d", &n);
    people* p = &head;
    int x = 0;
    while (n--)
    {
        x++;
        if (is_7(x))
        {
            p->number++;
            n++;
        }
        p = p->next;
    }
    int i = 0;
    p = &head;
    for (i; i < 4; i++)
    {
        printf("%d\n", p->number);
        p = p->next;
    }
}